package com.tsunade.spring6.autowired.controller;

import com.tsunade.spring6.autowired.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * @Project ：learn_spring
 * @File ：UserController.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/3/30 19:10
 * @Description ：For study.
 */

@Controller("myUserController")
public class UserController {
    // 注入service
    // 第一种方式：属性注入
    // @Autowired
    // private UserService userService;

    // 第二种方式：set方法注入
    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void add() {
        System.out.println("controller方法正在执行...");
        userService.add();
    }
}
